<?php
class Core_Driver_Firstform extends Core_Library_Form {
        
        public function startForm($values = array()){
                $htmlForm = "";
                $htmlForm .= "<form ";
                $htmlForm .= $this->useForeach($values);
                $htmlForm .= ">";
                return $htmlForm;               
        }
        
        function labelForm($values = array(), $textValue = null, $otherData = null){
                $htmlForm = "";
                $htmlForm .= "<label ";
                $htmlForm .= $this->useForeach($values)." ";
                $htmlForm .= $this->useOtherData($otherData);
                $htmlForm .= ">";
                $htmlForm .= $textValue;
                $htmlForm .= "</label>";
                return $htmlForm;
        }
        
        public function inputForm($values = array(), $otherData = null){
                $htmlForm = "";
                $htmlForm .="<input ";
                $htmlForm .= $this->useForeach($values)." ";
                $htmlForm .= $this->useOtherData($otherData);
                $htmlForm .= ">";
                return $htmlForm;               
        }
        
        public function textareaForm($values = array(), $otherData = null, $textValue = null){
                $htmlForm = "";
                $htmlForm .= "<textarea ";
                $htmlForm .= $this->useForeach($values)." ";
                $htmlForm .= $this->useOtherData($otherData);
                $htmlForm .= ">";
                $htmlForm .= $textValue;
                $htmlForm .= "</textarea>";
                return $htmlForm;
        }
        
        public function selectForm($values = array(), $otherData = null, $options = null){
                $htmlForm = "";
                $htmlForm .= "<select ";
                $htmlForm .= $this->useForeach($values)." ";
                $htmlForm .= $this->useOtherData($otherData);
                $htmlForm .= ">";
                $htmlForm .= $this->generateOptions($options);
                $htmlForm .= "</select>";
                return $htmlForm;
        }
        
        public function endForm(){
                $htmlForm = "</form>";
                return $htmlForm;
        }
        
        private function generateOptions($options = null){
                $htmlForm = "";
                foreach($options as $key => $value){
                        $htmlForm .= "<option value=\"";
                        $htmlForm .= $key;
                        $htmlForm .= "\">";
                        $htmlForm .= $value;
                        $htmlForm .= "</option>";
                }
                return $htmlForm;
        }
        
        private function useOtherData($otherData){
                $htmlForm = $otherData;
                return $htmlForm;
        }
        
        private function useForeach($values = array()){
                $htmlForm = "";
                foreach($values as $key => $value){
                        $htmlForm .= $key;
                        $htmlForm .= " = \"";
                        $htmlForm .= $value;
                        $htmlForm .= "\" ";
                }
                return $htmlForm;
        }

}